
#include "ui_desktop_main.h"





LV_IMG_DECLARE(icon_word_adventure)
LV_IMG_DECLARE(icon_word_IntPho)
LV_IMG_DECLARE(icon_word_NatPho)
LV_IMG_DECLARE(icon_setting)
LV_IMG_DECLARE(icon_my_elf)
LV_IMG_DECLARE(icon_word_query)

LV_IMG_DECLARE(ui_img_status_charge_level_10);
LV_IMG_DECLARE(ui_img_status_charge_level_30);
LV_IMG_DECLARE(ui_img_status_charge_level_50);
LV_IMG_DECLARE(ui_img_status_charge_level_70);
LV_IMG_DECLARE(ui_img_status_charge_level_full);

LV_IMG_DECLARE(ui_img_status_charging_png);
LV_IMG_DECLARE(ui_img_status_wifi_connected_png);
LV_IMG_DECLARE(ui_img_status_wifi_not_connect_png);
LV_IMG_DECLARE(img_statusBar_charge);

LV_IMG_DECLARE(page_left)
LV_IMG_DECLARE(page_right)
/**********************
 *      TYPEDEFS
 **********************/
static lv_obj_t *desktop_screen = NULL;
static lv_group_t *desktop_group = NULL;

static void ui_desktop_event_cb(lv_event_t *e)
{
    LOG_INFO_WRAPPER("start");
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t *target = lv_event_get_target(e);

    if (event_code == LV_EVENT_KEY) {
        // 按键事件 获取按键值
        uint32_t lv_key = lv_event_get_key(e);
        switch (lv_key) {
            case LV_KEY_ENTER:{
                extern void ui_word_query_screen_show();
                ui_word_query_screen_show();
                break;
            }

        }
    }
}

static void ui_desktop_screen_init()
{
    if (desktop_group == NULL)
    {
        desktop_group = ui_set_indev_group(indev_keypad);
    }

    desktop_screen = ui_create_default_screen(lv_scr_act());
    lv_obj_t *main_panel = ui_create_column_default_panel(desktop_screen);
    ui_create_default_image_by_src(main_panel,&icon_word_query);

    lv_group_add_obj(desktop_group, desktop_screen);
    lv_obj_add_event_cb(desktop_screen, ui_desktop_event_cb, LV_EVENT_KEY, NULL);
    lv_obj_add_event_cb(desktop_screen, ui_desktop_event_cb, LV_EVENT_FOCUSED, NULL);
    lv_obj_add_event_cb(desktop_screen, ui_desktop_event_cb, LV_EVENT_DEFOCUSED, NULL);

}

void ui_desktop_show()
{
    LOG_INFO_WRAPPER("start");
    if (desktop_screen == NULL)
    {
        ui_desktop_screen_init();
    }
    else
    {
        // 设置焦点组
        lv_group_set_default(desktop_group);
        lv_indev_set_group(indev_keypad, desktop_group);
    }
}


